package cn.zfgc.jfinal.entity;


import com.alibaba.fastjson.JSONObject;

/**
 * Created by wangwang 2017/1/12
 */
public class ReturnDataDO {
    public static int RETURN_ERROR_CODE = 1;

    public static int RETURN_TRUE_CODE = 0;

    // 0表示正确 1表示错误
    private int errorCode;

    private String msg;

    private Object data;

    public ReturnDataDO() {
    }

    public ReturnDataDO(int errorCode, String msg, Object data) {
        this.errorCode = errorCode;
        this.msg = msg;
        this.data = data;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public static String returnJson(int code, String msg, Object o) {
        if (code == RETURN_TRUE_CODE) {
            return JSONObject.toJSONString(new ReturnDataDO(RETURN_TRUE_CODE, msg, o));
        } else
            return JSONObject.toJSONString(new ReturnDataDO(ReturnDataDO.RETURN_ERROR_CODE, msg, o));
    }
}
